<?php

require_once ('Zend/Sql/Adapter/Standard/Expression/Identifier/Schema.php');

class Zend_Sql_Adapter_Standard_Expression_Identifier_Table
	extends Zend_Sql_Adapter_Standard_Expression_Identifier_Schema
{
	/**
	 * @var string
	 */
	protected $table;
	
	public function __construct($name=null, $schema=null) {
		if (isset($name)) {
			$this->setTable($name);
		}
		parent::__construct($schema);
	}
	
	/**
	 * @return the $table
	 */
	public function getTable() {
		return $this->table;
	}

	/**
	 * @param string $table
	 */
	public function setTable($table) {
		$this->table = $table;
	}
	
	/**
	 * @return the $table
	 */
	public function toString() {
		$schema = parent::toString();
		if ($schema) {
			$schema = $schema . '.';
			if (!$this->table) {
				require_once ('Zend/Sql/Exception.php');
				throw new Zend_Sql_Exception('Unexcepted schema name or empty table name');
			}
		}
		
		$table = '';
		if ($this->table) {
			$table = $schema . '`' . $this->table . '`';
		}
		
		return $table;
	}
	
	/**
	 * override
	 * @return the $table
	 */
	public function getName() {
		return $this->getTable();
	}
	/**
	 * override
	 * @return the $table
	 */
	public function setName($name) {
		return $this->setTable($name);
	}
}
